#include <iostream>
#include <signal.h>
#include <unistd.h>

using namespace std;

void handler(int signum)
{
    cout << "子进程退出：" << signum << endl;
}
int main()
{
    signal(SIGCHLD, handler);   
    if (fork() == 0)
    {
        cout << "childpid:" << getpid() << endl;
        sleep(1);
        exit(0);
    }
    sleep(2);
    exit(0);
    while (true)
        sleep(1);
}